package com.soilflow.web.controller.know;

import com.soilflow.common.core.controller.BaseController;
import com.soilflow.common.core.domain.AjaxResult;
import com.soilflow.common.core.page.TableDataInfo;
import com.soilflow.common.domain.KnowsReport;
import com.soilflow.common.domain.dto.KnowsReportDto;
import com.soilflow.common.domain.vo.KnowsReportVo;
import com.soilflow.know.service.KnowsReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("report")
public class KnowsReportController extends BaseController {

    @Autowired
    private KnowsReportService knowsReportService;


    /**
     * 百事通举报信息列表
     * @param dto
     * @return
     */
    @GetMapping("/list")
    public TableDataInfo reportList(KnowsReportDto dto){
        startPage();
        List<KnowsReportVo>  list = knowsReportService.reportList(dto);
        return getDataTable(list);
    }


    /**
     * 添加百事通举报信息
     * @param dto
     * @return
     */
    @PostMapping("/add")
    public AjaxResult addReport(@RequestBody KnowsReportDto dto){
        knowsReportService.addReport(dto);
        return AjaxResult.success();
    }


    /**
     * 更新百事通举报信息
     * @param dto
     * @return
     */
    @PutMapping("/update")
    public AjaxResult updateReport(@RequestBody KnowsReportDto dto){
        knowsReportService.updateReport(dto);
        return AjaxResult.success();
    }


    /**
     * 获取举报信息详情
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public AjaxResult getReportById(@PathVariable Long id){
        KnowsReportVo vo = knowsReportService.getReportById(id);
        return AjaxResult.success(vo);
    }


    /**
     * 删除百事通举报信息
     * @param ids
     * @return
     */
    @DeleteMapping("/del/{ids}")
    public AjaxResult delReport(@PathVariable List<Long> ids){
        knowsReportService.removeByIds(ids);
        return AjaxResult.success();
    }


}
